package svc

import (
	"github.com/zeromicro/go-zero/core/stores/redis"
	"navi-mumbai/app/api/business/internal/config"
	"navi-mumbai/app/rpc/game/client/gameuser"
	"navi-mumbai/app/rpc/game/client/gamewallet"
	"navi-mumbai/app/rpc/pay/client/payuser"
	ucAdmin "navi-mumbai/app/rpc/usercenter/client/ucadmin"
	"navi-mumbai/app/rpc/usercenter/client/ucsys"
	"navi-mumbai/app/rpc/usercenter/client/ucusers"
	"navi-mumbai/app/rpc/wallet/client/walletsys"
	"navi-mumbai/app/rpc/wallet/client/walletusers"

	"github.com/zeromicro/go-zero/zrpc"
)

type ServiceContext struct {
	Config         config.Config
	UcUserRpc      ucusers.UcUsers
	UcAdminRpc     ucAdmin.UcAdmin
	GameWalletRpc  gamewallet.GameWallet
	GameUserRpc    gameuser.GameUser
	WalletUsersRpc walletusers.WalletUsers
	PayUserRpc     payuser.PayUser

	// for test
	WalletSysRpc walletsys.WalletSys
	UcSys        ucsys.UcSys

	RedisClient *redis.Redis
}

func NewServiceContext(c config.Config) *ServiceContext {
	sc := ServiceContext{
		Config:         c,
		UcUserRpc:      ucusers.NewUcUsers(zrpc.MustNewClient(c.UsercenterRpcConf)),
		GameWalletRpc:  gamewallet.NewGameWallet(zrpc.MustNewClient(c.GameRpcConf)),
		GameUserRpc:    gameuser.NewGameUser(zrpc.MustNewClient(c.GameRpcConf)),
		WalletUsersRpc: walletusers.NewWalletUsers(zrpc.MustNewClient(c.WalletRpcConf)),
		WalletSysRpc:   walletsys.NewWalletSys(zrpc.MustNewClient(c.WalletRpcConf)),
		PayUserRpc:     payuser.NewPayUser(zrpc.MustNewClient(c.PayRpcConf)),
		UcSys:          ucsys.NewUcSys(zrpc.MustNewClient(c.UsercenterRpcConf)),
		UcAdminRpc:     ucAdmin.NewUcAdmin(zrpc.MustNewClient(c.UsercenterRpcConf)),
	}

	sc.RedisClient = redis.MustNewRedis(c.Redis)

	return &sc
}
